<?php
header("Cache-Control:no-cache, must-revalidate");  
?>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<table border="0">
<tr>
<td width="100px" height="80px"><b>图书条码</b></td>
<td width="380px"><div class="input-group input-group-lg"><input type="text" class="form-control input-lg" style = "width:280px" id="bookCode">
	<input type="button"  class="btn btn-primary btn-lg" value="查找" id="search">
	</div></td>
<td width="150px"><input type="radio" name="type" value="1" checked><b> 根据图书条码</b></td>
<td width="150px"><input type="radio" name="type" value="2"><b> 根据用户姓名</b></td>
</tr>
</table>
<hr>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>No.</th>
<th>图书条码</th>
<th>图书名称</th>
<th>行为</th>
<th>操作者</th>
<th>时间</th>
</tr>
</thead>
<tbody id="history">
</tbody>
</table>
</div>
</div>
<script type="text/javascript">
$("#search").click(function(){
	var key = $("input[name='type']:checked").val();
	var value = $("#bookCode").val();

	$.ajax({
		type: 'POST',
		url: '../../controller/historyController.php',
		data: {
			hkey: key,
			kval: value
		},
		success: function(data){
			if(data == false){
				alert("查找失败 :(");
			}else{

				$("#history").empty();

				var historyJson = jQuery.parseJSON(data);

				for(var i = 0; i < historyJson.length; i++){

					var content = "<tr><td>"+historyJson[i].hid+"</td>"+
								  "<td>"+historyJson[i].hbcode+"</td>"+
								  "<td>"+historyJson[i].hbname+"</td>"+
								  "<td>"+historyJson[i].htype+"</td>"+
								  "<td>"+historyJson[i].huname+"</td>"+
								  "<td>"+historyJson[i].htime+"</td></tr>";

					$("#history").append(content);

				}
			}
			
		}
	})

})
</script>

